﻿#include <stdio.h>
#include <omp.h>
#include <assert.h>

int main() {
    int i = 1, j = 2;
    int* ptr_i = &i, * ptr_j = &j;

#pragma omp parallel private(i) firstprivate(j) num_threads(2)
    {
        int thread_id = omp_get_thread_num();
        i = 3 + thread_id;  
        j = j + thread_id;  

        printf("Thread %d: i=%d, j=%d\n", thread_id, i, j);

        assert(*ptr_i == 1 && *ptr_j == 2);
    }

    assert(i == 1 && j == 2);
    printf("\n主线程结果: i=%d, j=%d\n", i, j);

    return 0;
}